package com.igoal.web;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.igoal.web.model.BaseModel;

@Controller
public class GetContactController extends BaseController {
	
	public String getViewPrefix() {
		return BaseControllerDelegate.DEFAULT_VIEW_PREFIX;
	}
	
	@RequestMapping("/yahooContact.*")
	public String yahoo(ModelMap model, HttpServletRequest request) {
		getContact(model, request);
		return "redirect:closePopup.htm";
	}

	@RequestMapping("/googleContact.*")
	public String google(ModelMap model, HttpServletRequest request) {
		getContact(model, request);
		return "redirect:closePopup.htm";
	}

	private void getContact(ModelMap model, HttpServletRequest request) {
		// HttpSession session = request.getSession();
		//
		// // Person viewer = null;
		// List<Person> friends = new ArrayList<Person>();
		//
		// OAuth3LeggedScheme scheme = (OAuth3LeggedScheme) session
		// .getAttribute("scheme");
		//
		// if (scheme != null && scheme.getAccessToken() != null) {
		// Client client = new Client(scheme.getProvider(), scheme);
		//
		// try {
		// Map<String, Request> requests = new HashMap<String, Request>();
		// requests.put("friends", PeopleService.getFriends());
		// requests.put("viewer", PeopleService.getViewer());
		//
		// Map<String, Response> responses = client.send(requests);
		// friends = responses.get("friends").getEntries();
		// // viewer = responses.get("viewer").getEntry();
		// } catch (Exception e) {
		// e.printStackTrace();
		// }
		// }
		//
		// model.addAttribute("contactList", friends);
	}

	public void initTopPage(BaseModel model, HttpServletRequest request) {
		// TODO Auto-generated method stub
		
	}

	public void initRightPage(BaseModel model, HttpServletRequest request) {
		// TODO Auto-generated method stub
		
	}

	public void initLeftPage(BaseModel model, HttpServletRequest request) {
		// TODO Auto-generated method stub
		
	}
}
